//
//  CZAlbumViewController.m
//  i0S007通用项目
//
//  Created by Apple on 16/2/17.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "CZAlbumViewController.h"
#import "CZNetworkTool.h"
#import "CZWeatherViewModel.h"
#import "CZWeather.h"

@interface CZAlbumViewController ()

@property (strong, nonatomic) CZWeatherViewModel *weatherVM;
@end

@implementation CZAlbumViewController

static NSString * const reuseIdentifier = @"Cell";

- (instancetype)init {
    if (self = [super initWithCollectionViewLayout:[[UICollectionViewFlowLayout alloc] init]]) {
        
    }
    
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    CZNetworkTool *netWorkTool = [CZNetworkTool sharedInstance];
//    [netWorkTool queryWeatherWithProvince:@"广东" city:@"广州"];
    
    // 1.调用weatherVM vmQueryWeatherWithProvince 加载数据准备Block
    [self.weatherVM vmQueryWeatherWithProvince:@"广东" city:@"广州" vmFinshed:^(CZWeather *weather, NSError *error) {
        // 10.控制器获取到数据了
        if (error) {
            NSLog(@"在控制器知道网络请求数据失败了");
            return;
        }
        
        NSLog(@"在控制器获取到了天气模型:%@", weather);
    }];
}

#pragma mark - 懒加载
- (CZWeatherViewModel *)weatherVM {
    if (_weatherVM == nil) {
        _weatherVM = [[CZWeatherViewModel alloc] init];
    }
    
    return _weatherVM;
}
@end
